#ifndef THREAD_POOL_H_
#define THREAD_POOL_H_
#include "defs.h"

#include <vector>
#include "async_queue.h"

class Thread;
class ThreadPool{
	private:
		int _max_thread_count;
		int _cur_thread_count;
		std::vector<Thread*> _thread_list;
		AsyncQueue<Job*> _queue;
		bool _stop;
		
		void _add_a_thread();
	public:
		ThreadPool(int max_thread);
		~ThreadPool();
		
		void start();
		void stop();
		void cont();

		bool	queue_job(Job* job);
		Job*	get_job(long timeout = 0);
};
#endif
